from sqlalchemy import Column, Integer, String, DateTime, Boolean
from sqlalchemy.sql import func

from db.config import Base


class User(Base):
    __tablename__ = "user"

    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    username = Column(String(50), unique=True, nullable=False, index=True)
    password = Column(String(255), nullable=False)
    enable = Column(Boolean, default=True, nullable=False)
    create_time = Column("createTime", DateTime(timezone=True), server_default=func.now(), nullable=False)
    update_time = Column("updateTime", DateTime(timezone=True), server_default=func.now(), onupdate=func.now(),
                         nullable=False)
